﻿<%@ Page Language="C#" MasterPageFile="~/WebSite/manager.Master" AutoEventWireup="true" CodeFile="m_data_nationality.aspx.cs" Inherits="WebSite_m_data_nationality" Title="无标题页" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<style type="text/css">
        .InfoStyle
        {
        	margin:25px;
        	margin-left:0px;
        	width:650px;
        	overflow:visible;
       	}
       	.InfoStyle h1
       	{
       		font-size:20px;
       		background-image:url(../images/Clip.png);
       		background-repeat:no-repeat;
       		width:300px;
       		margin:-23px auto auto 180px;
       		padding-top:15px;
       		padding-left:50px;
       		height:40px;
       	}
       	.InsertBtnStyle
       	{
       		margin:5px 150px auto;
    	    width:90px;
    	    height:30px;
    	    background-color:#669DF0;
    	    font-size:16px;
    	    font-weight:bold;
    	    color:#FFFFFF;
       	}
       	.TableStyle
       	{
       		margin:0px 120px;
       	}
    </style>
    <div class="InfoStyle">
        <h1>民族代码信息表</h1>
        <br />
        <div class="TableStyle">
        <asp:GridView ID="UserDetailGridView" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False"
            DataSourceID="SqlDataSource1" CellPadding="4" Font-Size="15px"  DataKeyNames="NationalityId"
                                        PageSize="20" ForeColor="#333333" GridLines="None">
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Center" VerticalAlign="Middle" />
            <Columns>
                <asp:CommandField HeaderText="操作" ShowDeleteButton="True" 
                    ShowEditButton="True" />
                <asp:BoundField DataField="NationalityId" HeaderText="民族ID" 
                    SortExpression="NationalityId" ItemStyle-Width="130px" 
                    ControlStyle-Width="130px" >
                </asp:BoundField>
                <asp:BoundField DataField="Nationality" HeaderText="民族名称" 
                    SortExpression="Nationality" ControlStyle-Width="150px" 
                    ItemStyle-Width="150px"  >
                </asp:BoundField>
            </Columns>
            <FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#999999" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        </asp:GridView>
        <br />
        <table style="font-size:15px; text-align:center; margin-left:30px;">
            <tr>
                <td>民族ID</td>
                <td>民族名称</td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="NationalityIdTextBox" runat="server" EnableViewState="false" Wrap="false" Width="60px"  />
                </td>
                <td>
                    <asp:TextBox ID="NationalityTextBox" runat="server" EnableViewState="False" Wrap="False" Width="120px" MaxLength="5"/>
                </td>
           </tr>
        </table>
        <asp:Button ID="InsertBtn" runat="server" Text="插入信息" OnClick="InsertBtn_Click" 
                CssClass="InsertBtnStyle"/>
    </div> 
            
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
            ControlToValidate="NationalityIdTextBox" Display="Dynamic" 
            ErrorMessage="民族ID只能输入正整数" ValidationExpression="^[1-9]\d*$"></asp:RegularExpressionValidator>
        
        <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" 
            ControlToValidate="NationalityTextBox" Display="Dynamic" 
            ErrorMessage="民族名称只能输入中文" ValidationExpression="^[\u4e00-\u9fa5]+$"></asp:RegularExpressionValidator>

  <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:CSHDBConnectionString %>" 
            
        SelectCommand="SELECT NationalityId, LTRIM(RTRIM(Nationality)) AS Nationality FROM NationalityTable WHERE Nationality!='全部'" 
        DeleteCommand="DELETE FROM NationalityTable WHERE NationalityId=@original_NationalityId"  
        
        UpdateCommand="UPDATE NationalityTable SET NationalityId = @NationalityId, Nationality = @Nationality WHERE (NationalityId = @original_NationalityId)" 
        OldValuesParameterFormatString="original_{0}" >
            <DeleteParameters>
                <asp:Parameter Name="original_NationalityId" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="NationalityId" />
                <asp:Parameter Name="Nationality" />
                <asp:Parameter Name="original_Nationality" />
            </UpdateParameters>
        </asp:SqlDataSource>       
</div>

    <asp:Label ID="WarnLabel" runat="server" ForeColor="Red" Visible="false" /> 
</asp:Content>

